/*
*    Qizx/open 3.0 beta
*
* This code is the open-source version of Qizx.
* Copyright (C) 2004-2009 Axyana Software -- All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License 
*  Version 1.1 (the "License"); you may not use this file except in 
*  compliance with the License. You may obtain a copy of the License at
*  http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
*  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
*  for the specific language governing rights and limitations under the
*  License.
*
* The Initial Developer of the Original Code is Xavier Franc - Axyana Software.
*
*/
using System;
using ExprDisplay = System.Qizx.XQuery.ExprDisplay;
using ModuleContext = System.Qizx.XQuery.ModuleContext;
using XQItemType = System.Qizx.XQuery.XQItemType;
using XQType = System.Qizx.XQuery.XQType;
namespace System.Qizx.XQuery.Op
{
	
	/// <summary> class NodeComparison:</summary>
	public abstract class NodeComparison:BooleanExpression
	{
		public Expression expr1;
		
		public Expression expr2;
		
		public NodeComparison(Expression expr1, Expression expr2)
		{
			this.expr1 = expr1;
			this.expr2 = expr2;
		}
		
		public override void  Dump(ExprDisplay d)
		{
			d.binary(this, expr1, expr2);
		}
		
		public override Expression Child(int rank)
		{
			return (rank == 0)?expr1:((rank == 1)?expr2:null);
		}
		
		public override Expression StaticCheck(ModuleContext context, int flags)
		{
			expr1 = context.staticCheck(expr1, 0);
			XQItemType typ1 = expr1.getType().itemType();
			if (typ1 != XQType.ITEM)
				context.checkType(expr1, XQType.NODE.opt, "operand1");
			expr2 = context.staticCheck(expr2, 0);
			XQItemType typ2 = expr2.getType().itemType();
			if (typ2 != XQType.ITEM)
				context.checkType(expr2, XQType.NODE.opt, "operand2");
			type = XQType.BOOLEAN;
			return this;
		}
	}
}